How to Make a Stopwatch with Arduino and LCD

Arduino Stopwatch Project

Components Required

About 16x2 LCD Display

The name "16x2 LCD display" comes from the fact that it has 16 columns and 2 rows, meaning we can display 32 characters on this screen. Characters can be alphabets, numbers, or custom-made characters. Each column is made from a 5x8 matrix of pixels (40 pixels per column).

Pinouts

LCD Display Interfacing with Arduino

VSS and LED- are grounded. VCC and LED+ connect to Arduino’s 5V. A Preset is connected to VEE to adjust contrast. LCD pins are connected as follows:

Toggle switch connections:

Circuit Diagram

Circuit Diagram

Arduino Code


#include <LiquidCrystal.h>
LiquidCrystal lcd(6, 7, 8, 9, 10, 11, 12);
unsigned long currentTime = 0, previousTime = 0;
int centiseconds = 0, seconds = 0, minuites = 0, hours = 0, button = A0;

void setup() {
  pinMode(button, INPUT);
  lcd.begin(16, 2);
}

void loop() {
  if (digitalRead(button) == HIGH) {
    lcd.setCursor(0, 0);
    lcd.print("time stopped");
    delay(1000);
    while (digitalRead(button) == LOW);
    delay(1000);
  }
  if (centiseconds == 0) {
    lcd.clear();
  }
  currentTime = millis();
  centiseconds = currentTime / 10;
  seconds = currentTime / 1000;
  minuites = seconds / 60;
  hours = minuites / 24;

  centiseconds = centiseconds - seconds * 100;
  seconds = seconds - minuites * 60;
  minuites = minuites - hours * 60;

  lcd.setCursor(0, 0);
  lcd.print("Time elasped");
  lcd.setCursor(0, 1);
  lcd.print(hours);
  lcd.print(":");
  lcd.print(minuites);
  lcd.print(":");
  lcd.print(seconds);
  lcd.print(":");
  lcd.print(centiseconds);
}